<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <title>服务</title>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css"/>
    <style>
        .layui-form{width: 80%;margin: 0 auto;}
        .layui-input-block{width: 60%;}
    </style>
</head>
<body>
<form class="layui-form" action="" lay-filter="example" id="editForm">
    <div class="layui-row" style="margin-top: 20px;">
        <div class="layui-col-md6" >

            <div class="layui-form-item">
                <label class="layui-form-label">服务类型</label>
                <div class="layui-input-block">
                    <select name="serviceType" lay-filter="serviceType">
                        <option value="售前服务" selected="">售前服务</option>
                        <option value="售中服务">售中服务</option>
                        <option value="售后服务">售后服务</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">概要</label>
                <div class="layui-input-block">
                    <input type="text" id="outline" name="outline" lay-verify="required" autocomplete="off" placeholder="请输入概要" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">客户编号</label>
                <div class="layui-input-block">
                    <input type="text" id="cusId" name="cusId" lay-verify="required" placeholder="请输入客户" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务状态</label>
                <div class="layui-input-block">
                    <input type="text" id="state" name="state" lay-verify="required" placeholder="请输入服务状态" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务请求</label>
                <div class="layui-input-block">
                    <input type="text" id="request" name="request" lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务创建人</label>
                <div class="layui-input-block">
                    <input type="text" id="createPeople" name="createPeople" lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item" style="width: 100%;margin-top: 30px;">
        <div class="layui-input-block" style="width: 80%;margin: 0 auto;text-align: center;">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="putIn">提交</button>
            <!--<button type="submit" class="layui-btn" lay-submit="" lay-filter="update">保存修改</button>-->
        </div>
        <!--        把id输入框设为隐藏-->
        <div class="layui-form-item" hidden>
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <input type="hidden" id="id" name="id" lay-verify="title" autocomplete="off" placeholder="请输入id" class="layui-input">
            </div>
        </div>
    </div>
</form>

<script src="../../layui/layui.js" charset="utf-8"></script>
<script src="../../js/jquery3.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/area.js" type="text/javascript"></script>
<script src="../../js/select.js" type="text/javascript"></script>
<script>
    layui.use(['form'], function(){
        var form = layui.form;
        //判断是增加还是修改
        var myUrl = "";
        if($('#id').val() == ""){
            myUrl = "http://localhost:8080/crm/cusService/save";
        }else {
            myUrl = "http://localhost:8080/crm/cusService/update";
        }

        //监听添加
        form.on('submit(putIn)', function(data){
            layer.alert("恭喜你，操作成功！",{
                title: 'crm提示'
            })
            //向后台发送ajax请求
            $.ajax({
                //编写json格式，设置属性和值
                url:myUrl,
                contentType:"application/json;charset=utf-8",
                data:JSON.stringify(data.field),
                dataType:"json",
                type:"post",
                async:false,
                success:function (data){
                    //服务器端成功响应的json数据，进行解析
                },
                //刷新页面
                end:parent.location.reload(),
            })
            return false;
        });

    });

</script>
</body>
</html>